const fs = require('fs');

fs.readdir('./code', (err,data) => {
  if(err){
    console.log('读取失败');
    return
  }
  data.forEach(item => {
    let file = item.split('-');
    let [num,name] = file;
    // console.log(num,name)
    if(num < 10){
      num = '0' + num
    }
    fs.rename(`./code/${item}`,`./code/${num}-${name}`,err=> {
      if(err){
        console.log('重命名失败');
        return
      }
      console.log('重命名成功');

    })
  })
})